package main.CandidateAnalysis;

import java.io.Serializable;

/*
	Unstructured Text Entity Extraction System (UTEES)
	Programmer:	John Talburt
	Date:		September 13, 2008
	Filename:	UTEES_Candidate.java
	Purpose:	Candidate entity extracted from an Input Document
*/

public class UTEES_Candidate implements Cloneable, Serializable
{
	private int candidateID;
	private String documentType;
	private int documentID;
	private int LCxtfragmentID;
        private int RCxtfragmentID;
	private String entityName;
	private String entityValue;
	private int contextAmbiguity;
	private int minGroupAmbiguity;
	private int matchGroupSize;
	private double depthIndex;
	private int startPos;
	private int endPos;
	private boolean deleteFlag;
	private double score;
        private int token;
        private String preType, postType;
        private double ContextEval, Char_VecEval, TotalSupport;
        private String LCxt, RCxt;
        private boolean isCorrect;
        private int startTagPos, endTagPos;
        private Object miscAttr;
        private float lengthProbability, tokenProbability, charProbability;
        private float cxtAmbgRatio;
        private float LCxtAmbgRatio;
        private float RCxtAmbgRatio;
        private boolean LCxtAmbg;
        private boolean RCxtAmbg;

	public UTEES_Candidate()
	{
		deleteFlag = false;
                deleteFlag = false;
                isCorrect = false;
	}

	public void setCandidateID(int intVal) {candidateID = intVal;}
	public void setDocumentType(String strVal) {documentType = strVal;}
	public void setDocumentID(int intVal) {documentID = intVal;}
	public void setLCxtFragmentID(int intVal) {LCxtfragmentID = intVal;}
        public void setRCxtFragmentID(int intVal) {RCxtfragmentID = intVal;}
	public void setEntityName(String strVal) {entityName = strVal;}
	public void setEntityValue(String strVal){entityValue = strVal;}
	public void setContextAmbiguity(int intVal) {contextAmbiguity = intVal;}
	public void setMinGroupAmbiguity(int intVal) {minGroupAmbiguity = intVal;}
	public void setMatchGroupSize(int intVal) {matchGroupSize = intVal;}
	public void setDepthIndex(double dblVal) {depthIndex = dblVal;}
	public void setStartPos(int intVal) {startPos = intVal;}
	public void setEndPos(int intVal) {endPos = intVal;}
	public void setScore(double scr) {score = scr;}
        public void setToken(int intVal) {token = intVal;}
        public void setContextEval(double dblVal) {ContextEval = dblVal;}
        public void setChar_VecEval(double dblVal) {Char_VecEval = dblVal;}
        public void setTotalSupport(double dblVal) {TotalSupport = dblVal;}
        public void setPreType(String strVal){preType = strVal;}
        public void setPostType(String strVal){postType = strVal;}
        public void setNewLeft(String strVal){LCxt = strVal;}
        public void setNewRight(String strVal){RCxt = strVal;}
        public void setEndTagPos(int endTagPos) {this.endTagPos = endTagPos;}
        public void setStartTagPos(int startTagPos) {this.startTagPos = startTagPos;}
        public void setMiscAttr(Object miscObject) {this.miscAttr = miscObject;}
        public void setCharProbability(float charProbability) {this.charProbability = charProbability;}
        public void setLengthProbability(float lengthProbability) {this.lengthProbability = lengthProbability;}
        public void setTokenProbability(float tokenProbability) {this.tokenProbability = tokenProbability;}
        public void setCxtAmbgRatio(float cxtAmbgRatio) {this.cxtAmbgRatio = cxtAmbgRatio;}
        public void setLCxtAmbgRatio(float LCxtAmbgRatio) {this.LCxtAmbgRatio = LCxtAmbgRatio;}
        public void setRCxtAmbgRatio(float RCxtAmbgRatio) {this.RCxtAmbgRatio = RCxtAmbgRatio;}
        public void setLCxtAmbiguity(boolean LCxtAmbg) {this.LCxtAmbg = LCxtAmbg;}
        public void setRCxtAmbiguity(boolean RCxtAmbg) {this.RCxtAmbg = RCxtAmbg;}


    

    
    

	public int getCandidateID() {return candidateID;}
	public String getDocumentType() {return documentType;}
	public int getDocumentID() {return documentID;}
	public int getLCxtFragmentID() {return LCxtfragmentID;}
        public int getRCxtFragmentID() {return RCxtfragmentID;}
	public String getEntityName() {return entityName;}
	public String getEntityValue() {return entityValue;}
	public int getContextAmbiguity() {return contextAmbiguity;}
	public int getMinGroupAmbiguity() {return minGroupAmbiguity;}
	public int getMatchGroupSize() {return matchGroupSize;}
	public double getDepthIndex() {return depthIndex;}
	public int getStartPos() {return startPos;}
	public int getEndPos() {return endPos;}
	public double getScore() {return score;}
        public double getToken() {return token;}
        public double getContextEval() {return ContextEval;}
        public double getChar_VecEval() {return Char_VecEval;}
        public double getTotalSupport() {return TotalSupport;}
        public String getPreType(){return preType;}
        public String getPostType(){return postType;}
        public String getNewLeft(){return LCxt;}
        public String getNewRight(){return RCxt;}
        public int getEndTagPos() {return endTagPos;}
        public int getStartTagPos() {return startTagPos;}
        public Object getMiscAttr() {return miscAttr;}
        public float getCharProbability() {return charProbability;}
        public float getLengthProbability() {return lengthProbability;}
        public float getTokenProbability() {return tokenProbability;}
        public float getCxtAmbgRatio() {return cxtAmbgRatio;}
        public float getLCxtAmbgRatio() {return LCxtAmbgRatio;}
        public float getRCxtAmbgRatio() {return RCxtAmbgRatio;}
        public boolean isLCxtAmbiguous() {return LCxtAmbg;}
        public boolean isRCxtAmbigous() {return RCxtAmbg;}

	public void markAsDeleted() {deleteFlag = true;}
	public boolean isDeleted() {return deleteFlag;}

        public void markAsCorrect() {isCorrect = true;}
        public boolean isCorrect(){return isCorrect;}
        
	public boolean intersectsWith(UTEES_Candidate candidate)
	{
		int start = candidate.getStartPos();
		int end = candidate.getEndPos();
		if((start<=endPos) && (end>=startPos))
                {
                    return true;
                }
                else
                    return false;
	}

        public void print()
        {
            System.out.printf("%d|%d|%.5f|%s|%s|%d|%d|%.5f|%s|%s\n",
                            getCandidateID(), getLCxtFragmentID(), getScore(), getEntityName(),
                            getEntityValue(), getStartPos(), getEndPos(), getDepthIndex(),
                            getNewLeft(), getNewRight());
            
        }

    @Override
        public String toString()
        {
            String str = String.format("%d|%d|%d|%s|%s|%.5f|%s|%s|%.5f|", getCandidateID(), getLCxtFragmentID(), getRCxtFragmentID(),
                                       getDocumentType() + "." + getEntityName(), getEntityValue(), getDepthIndex(), getNewLeft(),
                                       getNewRight(), getScore());
            return str;
        }

    @Override
	public UTEES_Candidate clone() {
        try {
            return (UTEES_Candidate) super.clone();
        } catch (CloneNotSupportedException ex) {
            throw new InternalError();
        }
    }

    
}
